package cn.qqtheme.framework.picker;

import android.app.Activity;

/**
 * 数字选择器
 *
 * @author 李玉江[QQ :1032694760]
 * @version 2015 /10/24
 */
public class NumberPicker extends OptionPicker {

    /**
     * Instantiates a new Number picker.
     *
     * @param activity the activity
     */
    public NumberPicker(Activity activity) {
        super(activity, new String[]{});
    }

    /**
     * Sets range.
     *
     * @param startNumber the start number
     * @param endNumber   the end number
     */
    public void setRange(int startNumber, int end,String endNumber) {
        setRange(startNumber, end,endNumber, 1);
    }

    /**
     * Sets range.
     *
     * @param startNumber the start number
     * @param endNumber   the end number
     */
    public void setRange(int startNumber, int endNumber) {
        setRange(startNumber, endNumber, 1);
    }

    public void setRange2(int startNumber, int endNumber) {
        setRange2(startNumber, endNumber, 1);
    }

    /**
     * Sets range.
     *
     * @param startNumber the start number
     * @param endNumber   the end number
     * @param step        the step
     */
    public void setRange(int startNumber, int end,String endNumber, int step) {
        for (int i = startNumber; i <= end; i = i + step) {
            if(i == end) {
                options.add(endNumber);
            }else{
                options.add(String.valueOf(i));
            }
        }
    }

    /**
     * Sets range.
     *
     * @param startNumber the start number
     * @param endNumber   the end number
     * @param step        the step
     */
    public void setRange(int startNumber,int endNumber, int step) {
        for (int i = startNumber; i <= endNumber; i = i + step) {
            options.add(String.valueOf(i));
        }
    }

    public void setRange2(int startNumber,int endNumber, int step) {
        for (int i = startNumber; i <= endNumber;) {

            options.add(i+"");

            if(i<10){
                i++;
            }else if(i<100){
                i+=5;
            }else if(i<300){
                i+=10;
            }else if(i == 300){
                return;
            }
        }
    }

    /**
     * Sets selected item.
     *
     * @param number the number
     */
    public void setSelectedItem(int number) {
        setSelectedItem(String.valueOf(number));
    }

}

